﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using AtletIS.Shared.Helpers;

namespace AtletIS.Shared.Forms
{
    public partial class frmChipCorrections : Form
    {
        // Constructor
        public frmChipCorrections(int nStartNumber)
        {
            InitializeComponent();
            this.Icon = Properties.Resources.AtletIS64;

            if (nStartNumber != 0)
            {
                this.nudStartNumber.Value = nStartNumber;
            }
        }

        // Form Load
        private void frmChipCorrections_Load(object sender, EventArgs e)
        {
            DatabaseHelper.FillChipDataByStartNumber(this.aDbDataSet.ChipData, Convert.ToInt32(this.nudStartNumber.Value), Globals.ActiveCompetition.ID);
        }

        // GetData
        private void btnGetData_Click(object sender, EventArgs e)
        {
            DatabaseHelper.FillChipDataByStartNumber(this.aDbDataSet.ChipData, Convert.ToInt32(this.nudStartNumber.Value), Globals.ActiveCompetition.ID);
        }

        // Save
        private void tlsSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Validate();
                this.chipDataBindingSource.EndEdit();
                this.chipDataTableAdapter.Update(this.aDbDataSet.ChipData);

                MessageBox.Show("Zmeny boli uložené!", "Korekcie", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Nastala chyba pri ukladaní!" + Environment.NewLine + ex.Message, "Korekcie", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        // Close
        private void tlsClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        

        








    }
}
